//
//  PushViewController.m
//  BaiTuan
//
//  Created by mycomputer on 15/12/29.
//  Copyright © 2015年 YR. All rights reserved.
//

#import "PushViewController.h"
#import "MainTabBarController.h"
#import "WillTableView.h"
#import "WillTableViewCell.h"
#import "HWTabBarItem.h"
@interface PushViewController ()
@end

@implementation PushViewController
{
    WillTableViewCell *_cell;
    UITabBarController *_tab;
    WillTableView *_tableView;

}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    [self _bjView];
}
- (void)_createView{


}

//当没有数据 单元格时创建背景视图和跳转buttom
- (void)_bjView{
    if (_cell==nil) {
        UIView *bjView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 300)];
        UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(40, 0, 120, 120)];
        imgView.image = [UIImage imageNamed:@"bj_mine@2x"];
        UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 120, 200, 30)];
        label1.text = @"您还没有相关订单";
        label1.font = [UIFont systemFontOfSize:17];
        label1.textAlignment = NSTextAlignmentCenter;
        UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 150, 200, 30)];
        label2.text = @"去下一单试试吧";
        label2.font = [UIFont systemFontOfSize:14];
        label2.textColor = [UIColor lightGrayColor];
        label2.textAlignment = NSTextAlignmentCenter;
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame =CGRectMake(40, 180, 120, 40);
        button.layer.borderColor = [UIColor greenColor].CGColor;
        button.layer.borderWidth = 2;
        [button setTitle:@"随便逛逛" forState:UIControlStateNormal];
        [button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(_pushView:) forControlEvents:UIControlEventTouchUpInside];
        [bjView addSubview:label1];
        [bjView addSubview:label2];
        [bjView addSubview:imgView];
        [bjView addSubview:button];
        [self.view addSubview:bjView];
        bjView.center = self.view.center;
    }
}

//跳转首页
- (void)_pushView:(UIButton *)button{

    [self.navigationController popToRootViewControllerAnimated:YES];

    _tab = self.tabBarController;
    [self performSelector:@selector(test) withObject:nil afterDelay:0.1];
}


- (void)test
{
    NSInteger i = 0;
    NSArray *imageNames = @[@"tabbar11.png",@"tabbar12.png",@"tabbar13.png",@"tabbar14.png"];
    NSString *nameSd =@"tabbar21.png";
    NSArray *array = _tab.tabBar.subviews;
    for (UIView *view in array) {
        if ([view isKindOfClass:[HWTabBarItem class]]) {
            HWTabBarItem *btn = (HWTabBarItem *)view;
            NSString *name = imageNames[i];
             btn.tag = i;
            i++;
            [btn setSelected:NO sdName:nameSd name:name];
            if (btn.tag == 0) {
                [btn setSelected:(YES) sdName:nameSd name:name];
            }
        }
    }
    _tab.selectedIndex = 0;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)viewWillAppear:(BOOL)animated{
[self.navigationController.navigationBar.subviews objectAtIndex:0].alpha = 1;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
